<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>

<% 
  String username=(String) session.getAttribute("UserName");
	  if(username == null)
	  	username = "";
	  if(username.compareTo("admin") == 0 || username.compareTo("tien") == 0 )
	  {
		  //response.sendRedirect("index.jsp");
	  }
	  else
		  response.sendRedirect("ShowNotice2.jsp");
%>
<tiles:insertTemplate template="Template.jsp">

	<tiles:putAttribute name="head">
		<h1>Manager</h1>
	</tiles:putAttribute>
	
	<tiles:putAttribute name="body">
		

<h3 style="text-align: center; color: red;">${errors}</h3>
<form id="frmCategory" name="frmCategory" method="post" action="category.do">
  <table cellpadding="4px" cellspacing="4px" bgcolor="#F4F5F7" width="500px" class="tableBorder"
        align="center">
        <tr>
            <td colspan="2" bgcolor="#0071bd" align="center">
                <span class="message">MANAGER CATEGORIES</span>
            </td>
        </tr> 
    <tr>
      <td class="label" align="left" style="font-weight: bold">Category Id</td>
      <td><input readonly type="text" class="box" name="txtId" value="${cate.Id}"/></td>
    </tr>
    <tr>
      <td class="label" align="left" style="font-weight: bold">Category Name</td>
      <td><input size="44" type="text" class="box" name="txtName" value="${cate.Name}" /></td>
    </tr>
    <tr>
      <td class="label" align="left" style="font-weight: bold">Image</td>
      <td><input type="text" name="txtImage" class="box" value="${cate.Image}" /></td>
    </tr>
    <tr>
      <td class="label" align="left" style="font-weight: bold">Description</td>
      <td><textarea rows="2" cols="44" class="box" name="txtDescription">${cate.Description}</textarea></td>
    </tr>
    <tr>
      <td align="center" colspan="2" class="">
                <input type="submit" name="btnInsert" style="height: 30px;width: 100px;" class="btn btn-small btn-warning btn-success" value="Insert">
                &nbsp;
                <input type="submit" name="btnUpdate" style="height: 30px;width: 100px;" class="btn btn-small btn-warning btn-primary" value="Update">
                &nbsp;
                <input type="submit" name="btnDelete" style="height: 30px;width: 100px;"  class="btn btn-small btn-warning btn-danger" value="Delete">
            </td>
    </tr>
  </table>
  </form>

  <table class="table table-bordered" style="width: 90%;margin: 0px auto;">
  <tr align="center">
              		<td align="center" colspan="7">
	              		<form class="form-search" action="category.do" method="post">
	    					<input type="text" name="txtSearch" class="input-medium search-query">
	    					<input type="submit" name="btnSearch" class="btn" value="Search">
	    				</form>
              		</td>
              	</tr>
    <tr bgcolor="lightgray">
      <th>Id</th>
      <th>Name</th>
      <th>Image</th>
      <th>Description</th>
      <th>&nbsp;</th>
    </tr>
    <c:forEach var="c" items="${cates.rows}">
    <tr>
      <td>${c.Id}</td>
      <td>${c.Name}</td>
      <td>${c.Image}</td>
      <td>${c.Description}</td>
      <td><a href="?lnkEdit&txtId=${c.Id}">Edit</a></td>
    </tr>
    </c:forEach>
    </table>
</form>	
		
		
		
	</tiles:putAttribute>
	
</tiles:insertTemplate>